package com.wuhan.template.module.home.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.wuhan.template.R;
import com.wuhan.template.base.BaseViewHolder;
import com.wuhan.template.base.MyBaseAdapter;
import com.wuhan.template.module.home.entity.JieMuListViewEntity;

import java.util.List;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/12 0012.
 */
public class JiemuDanAdapter extends MyBaseAdapter<JieMuListViewEntity> implements View.OnClickListener {

    private List<JieMuListViewEntity> list;
    private Context context;
    private JieMuListViewEntity item;

    public JiemuDanAdapter(Context context, List<JieMuListViewEntity> list) {
        super(context, list);
        this.context=context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.jiemudan_list_item;
    }

    @Override
    public BaseViewHolder getViewHolder() {

        return new ViewHolder();
    }

    @Override
    public void bindViews(View view, BaseViewHolder viewHolder) {
        ViewHolder holder = (ViewHolder) viewHolder;
        item = getItem(holder.position);
        holder.time.setText(item.getStart());
        holder.name.setText(item.getTheme());
       /* view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, DianShiDateilActivity.class);
                intent.putExtra("m3u8", item.getM3u8());
                intent.putExtra("dianshiId", item.getChannel_id());
                context.startActivity(intent);

            }
        });*/
        view.setOnClickListener(this);


    }

    private OnVideoClickListener onVideoClickListener = null;

    @Override
    public void onClick(View v) {
        if(onVideoClickListener!=null){
            onVideoClickListener.onVideoItemClick(v,item.getM3u8(),item.getChannel_id());
        }
    }

    public static interface OnVideoClickListener{

        void onVideoItemClick(View view , String m3u8,String dianshiId);
    }

    public void setOnItemClickListener(OnVideoClickListener listener) {
        this.onVideoClickListener = listener;
    }

    public static class ViewHolder extends BaseViewHolder{
       @BindView(R.id.jiemu_image)
        ImageView imageLogo;
        @BindView(R.id.jiemu_stateImag)
        ImageView imageState;
        @BindView(R.id.jiemu_title)
        TextView name;
        @BindView(R.id.jiemu_time)
        TextView time;
    }
}
